#encoding:utf8

import sys
import os
import subprocess

def main():
	cmd		= ['start', sys.executable]
	# 如果ipython存在，比如路径为 C:\Python27\Scripts\ipython， 则优先打开它
	directory	= os.path.join(sys.prefix, 'Scripts')
	candidates	= ['ipython.py', 'ipython3-script.py']
	for name in candidates:
		path	= os.path.join(directory, name)
		if os.path.exists(path):
			cmd.append(path)

	# 使用了shell指令start
	subprocess.Popen(cmd, shell= True)

if __name__=='__main__':
	main()
